# python
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS

db = SQLAlchemy()

def create_app():
    app = Flask(__name__)
    app.config.from_object('config.Config')

    db.init_app(app)
    CORS(app)
    with app.app_context():
        from .models import user
        from .routes .user_routes import user_bp
        from .routes.food_routes import food_bp
        from .routes.category_routes import category_bp
        from .routes.user_info_route import user_info_bp
        app.register_blueprint(user_bp)
        app.register_blueprint(food_bp)
        app.register_blueprint(category_bp)
        app.register_blueprint(user_info_bp)
        db.create_all()

    return app